﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 巡航突击导弹
/// </summary>
public class CruiseAssaultMissile : Missile {

	public GameObject Afterburner;
	public bool isReclaim = false;
	private float time = 0;

	void FixedUpdate()
	{
		if (isReclaim) 
		{
			time += Time.fixedDeltaTime;
			if (time >= 0.4f) 
			{
				PoolControl.instance.cruiseAssaultMissilePool.Store(gameObject);
				isInPool = true;
				isReclaim = false;	
				time = 0;
			}
		}
	}
//
//	void OnTriggerEnter2D(Collider2D collision)
//	{
//		if(trigger)
//		{
//			// 子弹碰到敌人
//			if(collision.tag == "Enemy")
//			{
//				if(!isInPool)
//				{
//					//					print("碰到敌人");
//
//					// collision.gameObject.SendMessage("TakeDamage", damage);
//					StoreInPool();
//
//				}
//			}
//		}
//		else
//		{
//			// 子弹碰到hero
//			if(collision.tag == "Hero")
//			{
//				if(collision.gameObject != null)
//				{
//					//					print("碰到hero");
//					// collision.gameObject.SendMessage("TakeDamage", damage);
//					StoreInPool();
//				}
//			}
//		}
//	}

	public override void StoreInPool ()
	{
		Afterburner.GetComponent<Afterburner>().Stop();
		isAttack = false;
		MissileExplode();
		transform.position = new Vector3(1000, 1000, 0);
		timer = 0;
		target = null;
		isReclaim = true;
	}
		
}
